<?php

class MBreadcrumb extends CI_Model {

  //parameters

  private $xml;



	function __construct()

	{

		parent::__construct();

	}
	public function info_form_id($id)
	{
		if(is_numeric($id) && $id !="")
		{
		$this->db->where('cate_id =',$id);
		return $this->db->get("categories")->row_array();
		}
		else
			return false;
	}
function get_cate_from_sub($sub)
{
	$this->db->where("sub_cate_id",$sub);
	$this->db->join("categories","categories.cate_id = sub_categories.cate_id");
	$query =$this->db->get("sub_categories");
	if($query->num_rows() >0)
	{
		return $query->row_array();
	}
	else
	return false;
}
function get_cate_from_prod($prod)
{
	$this->db->select('sub_categories.*,products.*,categories.*,image,price_old,price_new,unit.id as unit_id,unit.name as unit_name');
	$this->db->where("products.id",$prod);
		$this->db->join("sub_categories","sub_categories.sub_cate_id = products.sub_id");
	$this->db->join("categories","categories.cate_id = sub_categories.cate_id");
	$this->db->join("unit" , "unit.id = unit" );
	$query =$this->db->get("products");
	if($query->num_rows() >0)
	{
		return $query->row_array();
	}
	
	else
	return false;
}

  function load_file()

  {

    $file_path = 'includes/cache/breadcrumb.xml';

    $this->xml = simplexml_load_file($file_path);

  }



  function translate_name($code)

  {

    $this->load_file();

    $type = $this->xml->type;

    foreach ($type as $row)

    {

      if ($row['CODE'] == $code)

      {

        return $row;

      }

    }

    return false;

  }

	

}//end model class





/* End of file mbreadcrumb.php */

/* Location: ./system/application/models/mbreadcrumb.php */

?>